using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace AdaptiveHelpDesk.AUI_Model_Components.Watcher.Combo_box
{
    class InteractionTechnique
    {


        #region AVERAGE DWELL TIME

            public decimal getAvgDwellTime(decimal totalDwellTime, int nrItemsVisited)
            {
                if (totalDwellTime.Equals(0))
                {
                    return 0;
                }
                else
                {
                    return decimal.Round((totalDwellTime / nrItemsVisited), 3);
                }
            }

        #endregion


        #region NR ITEMS VISITED

            public int getNrItems(int nrItemsVisited)
            {
                return nrItemsVisited;
            }

        #endregion


        #region UNIQUE ITEM VISITS

            public void addSelectedItemsToHashTable(Hashtable uniqueItems, String selectedItem)
            {
                if (uniqueItems.ContainsKey(selectedItem))
                {
                    //you update the value
                    string valueStr = uniqueItems[selectedItem].ToString();
                    int value = Convert.ToInt32(valueStr);
                    value++;
                    uniqueItems[selectedItem] = value;
                }
                else
                {
                    uniqueItems.Add(selectedItem, 1);
                }
            }


            public int getUniqueItemsVisited(Hashtable uniqueItems)
            {
                int nrUniqueItems = 0;
                foreach (DictionaryEntry de in uniqueItems)
                {
                    int value = (int)de.Value;
                    if (value == 1)
                    {
                        nrUniqueItems++;
                    }

                }
                return nrUniqueItems;
            }


        #endregion


        #region SELECTION TIME

            public decimal getSelectionTime(decimal selectionTime)
            {
                return selectionTime;
            }

        #endregion

    }
}
